<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
                "http://www.w3.org/TR/REC-html40/loose.dtd">
<html>
<head>
  <title>Description of errbayes</title>
  <meta name="keywords" content="errbayes">
  <meta name="description" content="ERRBAYES Evaluate Bayesian error function for network.">
  <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  <meta name="generator" content="m2html &copy; 2003 Guillaume Flandin">
  <meta name="robots" content="index, follow">
  <link type="text/css" rel="stylesheet" href="../../m2html.css">
</head>
<body>
<a name="_top"></a>
<div><a href="../../menu.html">Home</a> &gt;  <a href="#">ReBEL-0.2.7</a> &gt; <a href="#">netlab</a> &gt; errbayes.m</div>

<!--<table width="100%"><tr><td align="left"><a href="../../menu.html"><img alt="<" border="0" src="../../left.png">&nbsp;Master index</a></td>
<td align="right"><a href="menu.html">Index for .\ReBEL-0.2.7\netlab&nbsp;<img alt=">" border="0" src="../../right.png"></a></td></tr></table>-->

<h1>errbayes
</h1>

<h2><a name="_name"></a>PURPOSE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>ERRBAYES Evaluate Bayesian error function for network.</strong></div>

<h2><a name="_synopsis"></a>SYNOPSIS <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="box"><strong>function [e, edata, eprior] = errbayes(net, edata) </strong></div>

<h2><a name="_description"></a>DESCRIPTION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre class="comment">ERRBAYES Evaluate Bayesian error function for network.

    Description
    E = ERRBAYES(NET, EDATA) takes a network data structure  NET together
    the data contribution to the error for a set of inputs and targets.
    It returns the regularised error using any zero mean Gaussian priors
    on the weights defined in NET.

    [E, EDATA, EPRIOR] = ERRBAYES(NET, X, T) additionally returns the
    data and prior components of the error.

    See also
    <a href="glmerr.html" class="code" title="function [e, edata, eprior, y, a, mse] = glmerr(net, x, t)">GLMERR</a>, <a href="mlperr.html" class="code" title="function [e, edata, eprior, mse] = mlperr(net, x, t)">MLPERR</a>, <a href="rbferr.html" class="code" title="function [e, edata, eprior] = rbferr(net, x, t)">RBFERR</a></pre></div>

<!-- crossreference -->
<h2><a name="_cross"></a>CROSS-REFERENCE INFORMATION <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
This function calls:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="netpak.html" class="code" title="function w = netpak(net)">netpak</a>	NETPAK	Combines weights and biases into one weights vector.</li></ul>
This function is called by:
<ul style="list-style-image:url(../../matlabicon.gif)">
<li><a href="evidence.html" class="code" title="function [net, gamma, logev] = evidence(net, x, t, num)">evidence</a>	EVIDENCE Re-estimate hyperparameters using evidence approximation.</li><li><a href="glmerr.html" class="code" title="function [e, edata, eprior, y, a, mse] = glmerr(net, x, t)">glmerr</a>	GLMERR Evaluate error function for generalized linear model.</li><li><a href="mlperr.html" class="code" title="function [e, edata, eprior, mse] = mlperr(net, x, t)">mlperr</a>	MLPERR Evaluate error function for 2-layer network.</li><li><a href="rbferr.html" class="code" title="function [e, edata, eprior] = rbferr(net, x, t)">rbferr</a>	RBFERR	Evaluate error function for RBF network.</li></ul>
<!-- crossreference -->


<h2><a name="_source"></a>SOURCE CODE <a href="#_top"><img alt="^" border="0" src="../../up.png"></a></h2>
<div class="fragment"><pre>0001 <a name="_sub0" href="#_subfunctions" class="code">function [e, edata, eprior] = errbayes(net, edata)</a>
0002 <span class="comment">%ERRBAYES Evaluate Bayesian error function for network.</span>
0003 <span class="comment">%</span>
0004 <span class="comment">%    Description</span>
0005 <span class="comment">%    E = ERRBAYES(NET, EDATA) takes a network data structure  NET together</span>
0006 <span class="comment">%    the data contribution to the error for a set of inputs and targets.</span>
0007 <span class="comment">%    It returns the regularised error using any zero mean Gaussian priors</span>
0008 <span class="comment">%    on the weights defined in NET.</span>
0009 <span class="comment">%</span>
0010 <span class="comment">%    [E, EDATA, EPRIOR] = ERRBAYES(NET, X, T) additionally returns the</span>
0011 <span class="comment">%    data and prior components of the error.</span>
0012 <span class="comment">%</span>
0013 <span class="comment">%    See also</span>
0014 <span class="comment">%    GLMERR, MLPERR, RBFERR</span>
0015 <span class="comment">%</span>
0016 
0017 <span class="comment">%    Copyright (c) Ian T Nabney (1996-2001)</span>
0018 
0019 <span class="comment">% Evaluate the data contribution to the error.</span>
0020 <span class="keyword">if</span> isfield(net, <span class="string">'beta'</span>)
0021   e1 = net.beta*edata;
0022 <span class="keyword">else</span>
0023   e1 = edata;
0024 <span class="keyword">end</span>
0025 
0026 <span class="comment">% Evaluate the prior contribution to the error.</span>
0027 <span class="keyword">if</span> isfield(net, <span class="string">'alpha'</span>)
0028    w = <a href="netpak.html" class="code" title="function w = netpak(net)">netpak</a>(net);
0029    <span class="keyword">if</span> size(net.alpha) == [1 1]
0030       eprior = 0.5*(w*w');
0031       e2 = eprior*net.alpha;
0032    <span class="keyword">else</span>
0033       <span class="keyword">if</span> (isfield(net, <span class="string">'mask'</span>))
0034          nindx_cols = size(net.index, 2);
0035          nmask_rows = size(find(net.mask), 1);
0036          index = reshape(net.index(logical(repmat(net.mask, <span class="keyword">...</span>
0037             1, nindx_cols))), nmask_rows, nindx_cols);
0038       <span class="keyword">else</span>
0039          index = net.index;
0040       <span class="keyword">end</span>
0041       eprior = 0.5*(w.^2)*index;
0042       e2 = eprior*net.alpha;
0043    <span class="keyword">end</span>
0044 <span class="keyword">else</span>
0045   eprior = 0;
0046   e2 = 0;
0047 <span class="keyword">end</span>
0048 
0049 e = e1 + e2;</pre></div>
<hr><address>Generated on Tue 26-Sep-2006 10:36:21 by <strong><a href="http://www.artefact.tk/software/matlab/m2html/">m2html</a></strong> &copy; 2003</address>
</body>
</html>